package io;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class FOSDemo {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("fos.dat");
        int d = fis.read();
        System.out.println(d);//1
        d = fis.read();//读取文件中第二个字节
        System.out.println(d);//13
        d = fis.read();//读取文件中第三个字节(文件末尾)
        System.out.println(d);//-1
        fis.close();
    }
    private void demo1() throws Exception{
        FileOutputStream fos = new FileOutputStream("word.txt");
        for (int i = 97;i <= 97+26;i++){
            fos.write(i);
        }
        fos.close();
    }
    private void demo2() throws Exception{
        FileOutputStream fos = new FileOutputStream("fos.dat");
        fos.write(1);
        fos.write(13);
        fos.close();
    }
}
